<?php

use backend\widgets\Bar;
use backend\grid\CheckboxColumn;
use backend\grid\ActionColumn;
use backend\grid\GridView;
use yii\widgets\Pjax;
use common\libs\Constants;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\search\OrderSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title                   = 'Orders';
$this->params['breadcrumbs'][] = yii::t('app', 'Order');
?>
<div class="row">
    <div class="col-sm-12">
        <div class="ibox">
            <?= $this->render('/widgets/_ibox-title') ?>
            <div class="ibox-content">
                <?= Bar::widget([
                    'template' => "{refresh}"
                ]) ?>
                <!--                --><? //= $this->render('_search', ['model' => $searchModel]); ?>
                <?php Pjax::begin(); ?>
                <?= GridView::widget([
                    'dataProvider' => $dataProvider,
                    'filterModel'  => $searchModel,
                    'columns'      => [
                        [
                            'class' => CheckboxColumn::className()
                        ],

//                        'id',
                        [
                            'attribute' => 'order_id',
                            'label'     => "订单号",
                        ],
                        [
                            'attribute' => 'uid',
                            'value'     => function ($model) {
                                return $model->u->username;
                            }
                        ],
                        [
                            'attribute' => 'status',
                            'filter'    => Constants::getOrderStatus(),
                            'value'     => function ($model) {
                                if (isset($model->status)) {
                                    return Constants::getOrderStatus($model->status);
                                }

                                return '-';
                            }
                        ],
                        [
                            'attribute' => 'type',
                            'filter'    => Constants::getOrderType(),
                            'value'     => function ($model) {
                                if (isset($model->type)) {
                                    return Constants::getOrderType($model->type);
                                }

                                return '-';
                            }
                        ],
//                        [
//                            'attribute' => 'good_id',
//                            'value'=>function($model){
//                                return $model->good->title;
//                            }
//                        ],
//                        'good_id',
                        // 'number',
                        // 'total_price',
                        // 'location',
                        // 'notify',
                        'created_at:datetime',
                        // 'updated_at',
                        // 'order_id',

                        [
                            'class'    => ActionColumn::className(),
                            'template' => "{view-layer}"
                        ],
                    ],
                ]); ?>
                <?php Pjax::end(); ?>            </div>
        </div>
    </div>
</div>
